<!DOCTYPE html>
<!-- 使用HTMLFormElement提供的属性和方法。完成一个可以进行简单加减乘除取余运算的计算器。
 -->
<html>
<head>
<meta charset="UTF-8">
<title>四则运算</title>
<script type="text/javascript">
	function calculate() {
		var num1 = parseFloat(document.getElementById("num1").value);
		var num2 = parseFloat(document.getElementById("num2").value);
		var val = document.getElementById("value").value;
		if (val == "+") {
			document.getElementById("num3").value = num1 + num2;
		} else if (val == "-") {
			document.getElementById("num3").value = num1 - num2;
		} else if (val == "*") {
			document.getElementById("num3").value = num1 * num2;
		} else if (val == "/") {
			document.getElementById("num3").value = num1 / num2;
		}

	};
</script>

</head>
<body>
	 
	<form>
		 
		<center>
			<fieldset style="height: 200px;">
				<legend>请输入要运算的数</legend>
				<input type="text" id="num1" value="" /> 
				<select name="cal" id="value">
					<option value="+">+</option>
					<option value="-">-</option>
					<option value="*">*</option>
					<option value="/">/</option>
				</select> 
			<input type="text" id="num2" value="" />= <input type="text" id="num3" value="" /> 
					
			<input type="button" value="提交" onClick="calculate()" />
					

			</fieldset>
			 
		</center>
		 
	</form>

</body>
</html>